<?php

namespace app\admin\model\superdata;

use think\Db;
use think\Model;


class Seriesactivity extends Model
{

    

    

    // 表名
    protected $table = 'series_activity';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'status_text',
    ];




    //新加状态字段
    public function getStatusList()
    {
        return ['0' => __('series_status 0'),'1' => __('series_status 1')];
    }
    //获取状态字段
    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : $data['status'];
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }



    /*
     * 查找用户的发布活动数量
    */
    public static function getSeriesCntByAdmId($uid){
        $count = Db::name("series_activity")->where('status',1)->where('admin_id',$uid)->count();
        if($count){
            return $count;
        }else{
            $count = 0;
            return $count;
        }


    }

}
